package com.bblocks.cacheTest;

import com.bblocks.cache.fresh.EnableUnactiveFresh;
import com.bblocks.cache.fresh.UnativeFreshProperties;
import org.springframework.beans.BeansException;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.CacheManager;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * 启动类 
 * @author Auster
 *
 */

@SpringBootApplication
@EnableUnactiveFresh
@ComponentScan(basePackages = {"com.bblocks.cacheTest","com.bblocks.cache"})
public class StartUpApplication implements ApplicationContextAware {
	public static void main(String[] args) {
		SpringApplication.run(StartUpApplication.class, args);
	}

	private static ApplicationContext applicationContext;
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.applicationContext = applicationContext;


		//@ConditionalOnBean({ CacheManager.class, RedisTemplate.class })
		CacheManager cm  =	applicationContext.getBean(CacheManager.class);
		RedisTemplate temp  =	(RedisTemplate)applicationContext.getBean("redisTemplate");

		UnativeFreshProperties properties  =	applicationContext.getBean(UnativeFreshProperties.class);
		System.out.println(properties);
	}

}
